#!/usr/bin/python
#coding: utf-8

"""
向网页上面上传文件

上传网页的 html 文件为 upload_file.html
"""

import os
import time
from selenium import webdriver

file_path = "file:///" + os.path.abspath("upload_file.html")
print file_path

driver = webdriver.Chrome()

try:
	driver.get(file_path)
	# send_keys 中是要上传的文件
	# 点击name是文件的按键以后会弹出选择文件框，此时 通过 send_keys 来输入上传文件的路径
	driver.find_element_by_name("file").send_keys("C:\\Users\Administrator\Desktop\test\upload_file.html")
	
	time.sleep(3)
except Exception as e:
	print e
finally:
	driver.quit()